package com.omronservice.app.curve.service;


import com.omronservice.app.curve.bean.dayscurve.DaysCurve2Bean;
import com.omronservice.app.curve.bean.dayscurve.DaysCurveBean;
import com.omronservice.app.curve.mapper.DaysCurveMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;


@Service
public class DaysCurveService {


    @Autowired
    DaysCurveMapper daysCurveMapper;


    public DaysCurveBean selectDays1(String line,String index) {
        DaysCurveBean daysCurveBean = new DaysCurveBean();
        List list0=new ArrayList();
        List list1=new ArrayList();
        List list2=new ArrayList();
        List list3=new ArrayList();
        List list4=new ArrayList();
        List list5=new ArrayList();
        List list6=new ArrayList();
        for(HashMap<String,String> map:daysCurveMapper.selectDays1(line,index)){
            list0.add(map.get("yValue0"));
            list1.add(map.get("yValue1"));
            list2.add(map.get("yValue2"));
            list3.add(map.get("yValue3"));
            list4.add(map.get("yValue4"));
            list5.add(map.get("yValue5"));
            list6.add(map.get("yValue6"));
        }
        daysCurveBean.setList0(list0);
        daysCurveBean.setList1(list1);
        daysCurveBean.setList2(list2);
        daysCurveBean.setList3(list3);
        daysCurveBean.setList4(list4);
        daysCurveBean.setList5(list5);
        daysCurveBean.setList6(list6);

        return daysCurveBean;
    }

    public DaysCurve2Bean selectDays2(String line,String startDate,String endDate,String type) {
        DaysCurve2Bean daysCurveBean = new DaysCurve2Bean();

        String weighNo1 = "";
        String weighNo2 = "";
        switch (type){
            case "1":
                weighNo1 = "2";
                weighNo2 = "3";
                break;
            case "2":
                weighNo1 = "4";
                weighNo2 = "5";
                break;
            case "3":
                weighNo1 = "6";
                weighNo2 = "7";
                break;
                default:
                weighNo1 = "2";
                weighNo2 = "3";
        }
        daysCurveBean.setList(daysCurveMapper.selectDays2(line,startDate,endDate,weighNo1,weighNo2));
        return daysCurveBean;
    }

}
